home *** CD-ROM | disk | FTP | other *** search
/ Amiga Game-Power / Amiga Game-Power.iso / anwendungen / gw print / structurebrowser_v1.3 / sources / sbgadget.c < prev    next >
C/C++ Source or Header  |  1994-05-20  |  9KB  |  262 lines

  1. /*
  2.    Handles the Gadget, StringInfo and PropInfo structures
  3.  
  4.       Not implemented:
  5.          StringInfo.AltKeyMap
  6. */
  7.  
  8. #include "header/sb.h"
  9.  
  10. extern int level;
  11.  
  12. /* PrGadget
  13.  
  14.    Put up the data for a Gadget structure.
  15. */
  16.  
  17. PrGadget(string, gadget)
  18. char *string;
  19. struct Gadget *gadget;
  20. {
  21. static struct StructData structdata [] = {
  22.    { " NextGadget",   "struct Gadget *",     PRPTR,   PTRSIZE },
  23.    { "-LeftEdge",     "SHORT",               PRINT,   INTSIZE },
  24.    { "-TopEdge",      "SHORT",               PRINT,   INTSIZE },
  25.    { "-Width",        "SHORT",               PRINT,   INTSIZE },
  26.    { "-Height",       "SHORT",               PRINT,   INTSIZE },
  27.    { " Flags",        "USHORT",              PRUINT,  INTSIZE },
  28.    { " Activation",   "USHORT",              PRUINT,  INTSIZE },
  29.    { " GadgetType",   "USHORT",              PRUINT,  INTSIZE },
  30.    { " GadgetRender", "APTR",                PRPTR,   PTRSIZE },
  31.    { " SelectRender", "APTR",                PRPTR,   PTRSIZE },
  32.    { "-GadgetText",   "struct IntuiText *",  PRPTR,   PTRSIZE },
  33.    { "-MutualExclude","LONG",                PRLONG,  PTRSIZE },
  34.    { " SpecialInfo",  "APTR",                PRPTR,   PTRSIZE },
  35.    { "-GadgetID",     "USHORT",              PRUINT,  INTSIZE },
  36.    { "-UserData",     "APTR",                PRPTR,   PTRSIZE },
  37. };
  38.  
  39. static char *flagnames[16] = {
  40.    "GADGHBOX",       "GADGHIMAGE",    "GADGIMAGE",      "GRELBOTTOM",
  41.    "GRELRIGHT",      "GRELWIDTH",     "GRELHEIGHT",     "SELECTED",
  42.    "GADGDISABLED"
  43. };
  44.  
  45. static char *activenames[16] = {
  46.    "RELVERIFY",      "GADGIMMEDIATE", "ENDGADGET",      "FOLLOWMOUSE",
  47.    "RIGHTBORDER",    "LEFTBORDER",    "TOPBORDER",      "BOTTOMBORDER",
  48.    "TOGGLESELECT",   "STRINGCENTER",  "STRINGRIGHT",    "LONGINT",
  49.    "ALTKEYMAP",      "BOOLEXTEND"
  50. };
  51.  
  52. static char *systypenames[16] = {
  53.    "SIZING",         "WDRAGGING",     "SDRAGGING",      "WUPFRONT",
  54.    "SUPFRONT",       "WDOWNBACK",     "SDOWNBACK",      "CLOSE",
  55.    NULL,             NULL,            NULL,             NULL,
  56.    "REQGADGET",      "GZZGADGET",     "SCRGADGET",      "SYSGADGET"
  57. };
  58.  
  59. static char *applitypenames[16] = {
  60.    "BOOLGADGET",     "GADGET0002",    "PROPGADGET",     "STRGADGET",
  61.    NULL,             NULL,            NULL,             NULL,
  62.    NULL,             NULL,            NULL,             NULL,
  63.    "REQGADGET",      "GZZGADGET",     "SCRGADGET",      "SYSGADGET"
  64. };
  65.  
  66. int i, sum, choice = -1;
  67. USHORT bits;
  68.  
  69.    level++;
  70.  
  71.    while (choice)
  72.    {
  73.       sum = SetOptionText(string, structdata, (APTR)gadget, DATASIZE, 0);
  74.  
  75.       switch (choice = GetChoice(DATASIZE))
  76.       {
  77.          case 1:
  78.             if (gadget->NextGadget)
  79.                PrGadget("The next gadget in Intuition's list",
  80.                   gadget->NextGadget);
  81.             break;
  82.          case 6:
  83.             bits = gadget->Flags;
  84.  
  85.             switch (bits & GADGHIGHBITS)
  86.             {
  87.                case 0:
  88.                   flagnames[0] = "GADGHCOMP";
  89.                   bits |= 0x01;
  90.                   break;
  91.                case 1:
  92.                   flagnames[0] = "GADGHBOX";
  93.                   break;
  94.                case 2:
  95.                   flagnames[1] = "GADGHIMAGE";
  96.                   break;
  97.                case 3:
  98.                   flagnames[1] = "GADGHNONE";
  99.                   bits ^= 0x01;
  100.                   break;
  101.             }
  102.             FlagPrint("Flags set for this gadget", flagnames, (ULONG)bits);
  103.             break;
  104.          case 7:
  105.             FlagPrint("Activation flags set for this gadget",
  106.                   activenames, (ULONG)gadget->Activation);
  107.             break;
  108.          case 8:
  109.             bits = gadget->GadgetType;
  110.             if (bits & SYSGADGET) {
  111.                bits = (bits & 0xff00) | (1 << (((bits & 0xf0) >> 4) - 1));
  112.                FlagPrint("Gadget type flags set for this gadget",
  113.                      systypenames, (ULONG)bits);
  114.             }
  115.             else {
  116.                bits = (bits & 0xff00) | (1 << ((bits & 0x0f) - 1));
  117.                FlagPrint("Gadget type flags set for this gadget",
  118.                      applitypenames, (ULONG)bits);
  119.             }
  120.             break;
  121.          case 9:
  122.             if (gadget->GadgetRender)
  123.                if (gadget->Flags & GADGIMAGE)
  124.                   PrImage("This Gadget's Image structure",
  125.                         gadget->GadgetRender);
  126.                else
  127.                   PrBorder("This Gadget's Border structure",
  128.                         gadget->GadgetRender);
  129.             break;
  130.          case 10:
  131.             if (gadget->SelectRender)
  132.                if (gadget->Flags & GADGIMAGE)
  133.                   PrImage("This Gadget's alternate Image structure",
  134.                         gadget->SelectRender);
  135.                else
  136.                   PrBorder("This Gadget's alternate Border structure",
  137.                         gadget->SelectRender);
  138.             break;
  139.          case 13:
  140.             if (gadget->SpecialInfo)
  141.                if (gadget->GadgetType & STRGADGET)
  142.                   PrStringInfo("This Gadget's StringInfo structure",
  143.                         gadget->SpecialInfo);
  144.                else if (gadget->GadgetType & PROPGADGET)
  145.                   PrPropInfo("This Gadget's PropInfo structure",
  146.                         gadget->SpecialInfo);
  147.             break;
  148.       }
  149.    }
  150.    level--;
  151. }
  152.  
  153.  
  154. /* PrStringInfo
  155.  
  156.    Put up the data for a StringInfo structure.
  157. */
  158.  
  159. PrStringInfo (string, stringinfo)
  160. char *string;
  161. struct StringInfo *stringinfo;
  162. {
  163. static struct StructData structdata[] = {
  164.    { " *Buffer",        "UBYTE *",              PRSTRING, PTRSIZE },
  165.    { " *UndoBuffer",    "UBYTE *",              PRSTRING, PTRSIZE },
  166.    { "-BufferPos",      "SHORT",                PRINT,    INTSIZE },
  167.    { "-MaxChars",       "SHORT",                PRINT,    INTSIZE },
  168.    { "-DispPos",        "SHORT",                PRINT,    INTSIZE },
  169.    { "-UndoPos",        "SHORT",                PRINT,    INTSIZE },
  170.    { "-NumChars",       "SHORT",                PRINT,    INTSIZE },
  171.    { "-DispCount",      "SHORT",                PRINT,    INTSIZE },
  172.    { "-CLeft",          "SHORT",                PRINT,    INTSIZE },
  173.    { "-CTop",           "SHORT",                PRINT,    INTSIZE },
  174.    { " LayerPtr",       "struct Layer *",       PRPTR,    PTRSIZE },
  175.    { "-LongInt",        "LONG",                 PRLONG,   PTRSIZE },
  176.    { "(AltKeyMap",      "struct KeyMap *)",     PRPTR,    PTRSIZE }
  177. };
  178.  
  179. int i, sum;
  180. int choice = -1;
  181.  
  182.    level++;
  183.  
  184.    while (choice)
  185.    {
  186.       sum = SetOptionText(string, structdata, (APTR)stringinfo, DATASIZE, 0);
  187.  
  188.       switch (choice = GetChoice(DATASIZE))
  189.       {
  190.          case 1:
  191.             if (stringinfo->Buffer)
  192.                PrString("The contents of the String Gadget's text buffer",
  193.                      stringinfo->Buffer);
  194.             break;
  195.          case 2:
  196.             if (stringinfo->UndoBuffer)
  197.                PrString("The contents of the String Gadget's undo buffer",
  198.                      stringinfo->UndoBuffer);
  199.             break;
  200.          case 11:
  201.             if (stringinfo->LayerPtr)
  202.                PrLayer("The Layer structure for this String Gadget",
  203.                      stringinfo->LayerPtr);
  204.             break;
  205.       }
  206.    }
  207.    level--;
  208. }
  209.  
  210.  
  211. /* PrPropInfo
  212.  
  213.    Put up the data for a PropInfo structure.
  214. */
  215.  
  216. PrPropInfo (string, propinfo)
  217. char *string;
  218. struct PropInfo *propinfo;
  219. {
  220. static struct StructData structdata[] = {
  221.    { " Flags",          "USHORT",    PRUINT,   INTSIZE },
  222.    { "-HorizPot",       "USHORT",    PRUINT,   INTSIZE },
  223.    { "-VertPot",        "USHORT",    PRUINT,   INTSIZE },
  224.    { "-HorizBody",      "USHORT",    PRUINT,   INTSIZE },
  225.    { "-VertBody",       "USHORT",    PRUINT,   INTSIZE },
  226.    { "-CWidth",         "USHORT",    PRUINT,   INTSIZE },
  227.    { "-CHeight",        "USHORT",    PRUINT,   INTSIZE },
  228.    { "-HPotRes",        "USHORT",    PRUINT,   INTSIZE },
  229.    { "-VPotRes",        "USHORT",    PRUINT,   INTSIZE },
  230.    { "-LeftBorder",     "USHORT",    PRUINT,   INTSIZE },
  231.    { "-TopBorder",      "USHORT",    PRUINT,   INTSIZE }
  232. };
  233.  
  234. static char *flagnames[16] = {
  235.    "AUTOKNOB",       "FREEHORIZ",     "FREEVERT",       "PROPBORDERLESS",
  236.    NULL,             NULL,            NULL,             NULL,
  237.    "KNOBHIT"
  238. };
  239.  
  240. int choice;
  241.  
  242.    level++;
  243.  
  244.    do
  245.    {
  246.       SetOptionText(string, structdata, (APTR)propinfo, DATASIZE, 0);
  247.  
  248.       switch (choice = GetChoice(DATASIZE))
  249.       {
  250.          case 1:
  251.             FlagPrint("Flags set for this PropInfo structure",
  252.                   flagnames, (ULONG)propinfo->Flags);
  253.             break;
  254.       }
  255.    } while (choice);
  256.  
  257.    level--;
  258. }
  259.  
  260.  
  261.  
  262.